package com.example.demo.controller.vo;

import com.example.demo.domain.application.Application;
import com.example.demo.domain.platform.PlatformRelease;
import lombok.Getter;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 应用信息
 * @author yingjianhua
 */
@Getter
public class ApplicationInfo {

    public ApplicationInfo(Application application, List<PlatformRelease> platformReleases) {
        this.applicationName = application.getName();
        this.applicationCode = application.getCode();
        this.applicationScale = application.getScale().getCode();
        this.releaseInfoList = platformReleases.stream().map(ReleaseInfo::new).collect(Collectors.toList());
    }

    private String applicationName;
    private String applicationCode;
    private String applicationScale;
    private List<ReleaseInfo> releaseInfoList;

    @Getter
    public static class ReleaseInfo {
        public ReleaseInfo(PlatformRelease platformRelease) {
            this.platform = platformRelease.getPlatform().name();
            this.type = platformRelease.getReleaseType().name();
            this.code = platformRelease.getCode();
        }

        private String platform;
        private String type;
        private String code;
    }
}
